//
//  BNMakeController.m
//  BeautifulNote
//
//  Created by Apple on 2019/7/24.
//  Copyright © 2019 Maker. All rights reserved.
//

#import "BNMakeController.h"

#import <YYImage.h>

#import "BNMoodEditController.h"
#import "BNConnectController.h"

@interface BNMakeController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation BNMakeController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initViews];
}

- (void)initViews {
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    YYImage *image = [YYImage imageNamed:@"makeHeader.gif"];
    YYAnimatedImageView *iv = [[YYAnimatedImageView alloc] init];
    iv.image = image;
    iv.frame = CGRectMake(0, 0, ScreenWidth, 200);
    
    self.tableView.tableHeaderView = iv;
    
}
#pragma mark - [系统控件的TableViewProtocol]
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"makeCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"makeCell"];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    switch (indexPath.row) {
        case 0:
            cell.imageView.image = [UIImage imageNamed:@"addMind"];
            cell.textLabel.text = @"抒写心情日记";
            break;
        case 1:
            cell.imageView.image = [UIImage imageNamed:@"connect"];
            cell.textLabel.text = @"联系我们";
            break;
        default:
            break;
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0:
        {
            BNMoodEditController *vc = [BNMoodEditController new];
            [self presentViewController:vc animated:YES completion:nil];
        }
            break;
        case 1:
        {
            BNConnectController *vc = [BNConnectController new];
            [self presentViewController:vc animated:YES completion:nil];
        }
            break;
        default:
            break;
    }
}
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] init];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.backgroundColor = mainColor;
        _tableView.tableFooterView = [UIView new];
    }
    return _tableView;
}

@end
